package com.meal.test.model;

import com.google.common.collect.Maps;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Map;

/**
 * @Title: RocketConstant
 * @Description: RocketMQ常量类
 * @Author yangzhanghui
 * @Date 2020/5/4 23:39
 * @Version v1.0
 */
@Data
public class RocketConstant {

    @Data
    public static class Topic{
        public static final String PRAISE_TOPIC = "";
    }

    @Data
    public static class Tags{
        public static final String BASE_TAG = "";
    }

    @Data
    public static class ConsumerGroup{
        public static final String PRAISE_CONSUMER = "";
    }

    @Data
    @Configuration
    @EnableConfigurationProperties(RockPropertie.class)
    public static class RockProp {
        public static final Map<String, String> propMap = Maps.newHashMap();
        public final RockPropertie rockPropertie;

        @Autowired
        public RockProp(RockPropertie rockPropertie) {
            this.rockPropertie = rockPropertie;
        }

        @Bean
        public Map getTopic(){
            String topic = rockPropertie.getTopic();
            propMap.put("PRAISE_TOPIC", topic);
            return propMap;
        }
    }
}
